local que_lingxi = fk.CreateSkill {
    name = "que_lingxi",
    tags = { Skill.Limited, },
}

Fk:loadTranslationTable {
    ["que_lingxi"] = "灵汐",
    [":que_lingxi"] = "限定技，出牌阶段，你可以获得一名角色手牌区外所有区域的牌(含武将牌上的牌和装备区，判定区的牌)。",

    ["$que_lingxi1"] = " ",
    ["$que_lingxi2"] = " ",
}

que_lingxi:addEffect("active", {
    card_num = 0,
    target_num = 1,
    card_filter = Util.FalseFunc,
    target_filter = function(self, player, to_select, selected)
        local cards = {}
        for _, card in pairs(to_select.special_cards) do
            table.insertTableIfNeed(cards, card)
        end
        return (#cards > 0 or #to_select:getCardIds("ej") > 0) and #selected == 0 and to_select ~= player
    end,
    can_use = function(self, player)
        local cards = {}
        for _, to in ipairs(Fk:currentRoom().alive_players) do
            for _, card in pairs(to.special_cards) do
                table.insertTableIfNeed(cards, card)
            end
        end
        return (#cards > 0 or #table.filter(Fk:currentRoom().alive_players, function(p)
            return p ~= player and #p:getCardIds("ej") > 0
        end) > 0) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target = effect.tos[1]
        for _, pid in ipairs(effect.tos) do
            local cards = {}
            for _, card in pairs(target.special_cards) do
                table.insertTableIfNeed(cards, card)
            end
            for _, card in ipairs(target:getCardIds("ej")) do
                table.insertIfNeed(cards, card)
            end
            if #cards > 0 then
                room:moveCards({
                    from = target,
                    ids = cards,
                    to = player,
                    toArea = Card.PlayerHand,
                    moveReason = fk.ReasonJustMove,
                    proposer = player,
                    skillName = self.name,
                })
            end
        end
    end,
})

return que_lingxi
